<%--
  Created by IntelliJ IDEA.
  User: 懒瑶瑶
  Date: 2022/5/17
  Time: 14:31
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>问题反馈</title>
    <!--引入CSS文件和JS文件-->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/layui/css/layui.css"/>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/layui/layui.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/jquery-3.5.1.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/ajaxForm.js"></script>
    <script>
        layui.use(['form', 'laydate', 'layer','jquery'], function () {
            var form = layui.form, laydate = layui.laydate, layer = layui.layer,$=layui.jquery;
            //定义自定义验证规则
            form.verify({
                v_notallnum:function (val,item) {
                    if (/^\d+\d+\d$/.test(val)){
                        return "不能为数字"
                    }
                },
                v_pass:[
                    /^[\S]{0,20}$/,
                    '长度不能超过20个字'
                ],
            });
            laydate.render({
                elem:'#replyTime',
                type:'date'  //指定日期选择器的类型  date 年月日  time 时分秒 dattime年月日时分秒
            });
            laydate.render({
                elem:'#feedbackTime',
                type:'date'  //指定日期选择器的类型  date 年月日  time 时分秒 dattime年月日时分秒
            });

            //监听表单的提交
            form.on('submit(formbtn)',function(){
                var formData = new FormData($("#formsbt")[0]);
                $.ajax({
                    url:'${pageContext.request.contextPath}/holidaystudent/fankuiadd',
                    type : 'POST',
                    data : formData,
                    cache: false,
                    async: false,
                    processData : false,  //必须false才会避开jQuery对 formdata 的默认处理
                    contentType : false,  //必须false才会自动加上正确的Content-Type
                    mimeType:"multipart/form-data",
                    success:function(data){ //添加成功的回调函数
                        layer.msg('反馈提交成功！',{icon:6,offset:"auto",time:2000});//提示框
                        setTimeout(function(){
                            var index = parent.layer.getFrameIndex(window.name);
                            // parent.layer.close(index);//关闭弹出层
                            location.reload();//重新加载父页面表格
                        }, 2100);
                    }
                });
            });
        });
    </script>
</head>
<body><br/>

<form class="layui-form" id="formsbt" enctype="multipart/form-data">

    <div class="layui-form-item">
        <label class="layui-form-label">建议：</label>
        <div class="layui-input-inline">
            <textarea style="height: 60px" name="remark" class="layui-input" lay-verify="required|v_notallnum"></textarea>
        </div>
        <span style="font-size: 10px;color: red">※</span>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">上传图片：</label>
        <div class="layui-input-inline">
            <input style="width: 150px" type="file" name="fileface">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">部门：</label>
        <div class="layui-input-inline">
            <select name="depId">
                <c:forEach items="${bmlist}" var="s">
                    <option value="${s.depid}">${s.depName}</option>
                </c:forEach>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <button id="formbtn" type="button" lay-submit lay-filter="formbtn" class="layui-btn layui-btn-normal">
            提交
        </button>
<%--        <button id="reset" type="reset" lay-submit lay-filter="formbtn" class="layui-btn layui-btn-normal">--%>
<%--            重置--%>
<%--        </button>--%>
        <button id="reset" type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
</form>
</body>
</html>

